﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LeMigue.Scrum.Iterface.Model;
using LeMigue.TeamPortal.Base.Globalization;

namespace LeMigue.TeamPortal.Base.View
{
    public class IterationView : IGlobalization
    {
        protected Iteration _iteration;
        protected bool _select = false;

        public IterationView() { }

        public IterationView(Iteration iteration)
        {
            _iteration = iteration;
        }
        public IterationView(Iteration iteration, bool select)
            : this(iteration)
        {
            _select = select;
        }
        //TODO: melhorar a referencia para todas as views
        public Iteration Iteration
        {
            get { return _iteration; }
        }

        public int Id
        {
            get { return _iteration == null ? -1 : _iteration.Id; }
        }
        public int IdSprint
        {
            get { return HasSprint ? _iteration.Sprint.Id : -1; }
        }

        public string Title
        {
            get { return _iteration.Title; }
        }

        public string Start
        {
            get
            {
                if (this._iteration.Sprint != null && this._iteration.Sprint.Start != null)
                    return this.Resource("FormatoData1", this._iteration.Sprint.Start);

                return "";
            }
        }
        public string End
        {
            get
            {
                //TODO: resolver a questão dos recursos, pois este teoricamente está no portal e não na dll
                if (this._iteration.Sprint != null && this._iteration.Sprint.End != null)
                    return this.Resource("FormatoData1", this._iteration.Sprint.End);

                return "";
            }
        }

        public string Periodo
        {
            get { return Start != "" && End != "" ? this.Resource("FormatoPeriodo", Start, End) : ""; }
        }

        public string Atual
        {
            get { return this._iteration.Sprint != null && this._iteration.Sprint.Atual ? "atual" : ""; }
        }

        public string Selecionado
        {
            get { return _select ? "selecionado" : ""; }
        }

        public bool HasSprint
        {
            get { return this._iteration == null ? false : this._iteration.Sprint != null; }
        }

        public string Tipo
        {
            get{ return HasSprint ? "sprint": "iteration";}
        }
        //public bool Clicavel
    }
}
